﻿using DevExpress.XtraTab;
using Lamex.Common;
using Lamex.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Lamex.Library.CommonClass
{
    public class ModuleLoadDevComponent : ModuleLoaderBase
    {
        public override void LoadGUI(object mainTabControl)
        {
            if (mainTabControl == null) return;
            if (mainTabControl is XtraTabControl == false) return;
            XtraTabControl xtraTabControl = mainTabControl as XtraTabControl;
            try
            {
                Control contrainer = _ModuleMainForm.GetContainer();
                if (contrainer != null)
                {
                    contrainer.Dock = DockStyle.Fill;

                    XtraTabPage page = new XtraTabPage();

                    page.Text = _ModuleMainForm.ModuleName;
                    page.Tag = _ModuleMainForm;
                    page.Controls.Add(contrainer);
                    xtraTabControl.HeaderLocation = DevExpress.XtraTab.TabHeaderLocation.Bottom;
                    xtraTabControl.SelectedTabPage.ShowCloseButton = DevExpress.Utils.DefaultBoolean.True;
                    xtraTabControl.ClosePageButtonShowMode = ClosePageButtonShowMode.InAllTabPageHeaders;
                    xtraTabControl.TabPages.Add(page);

                }
            }
            catch (Exception ex)
            {
                MsgShow.ShowException(ex);
            }
        }
    }
}
